package esiag.pds.run;

import java.awt.HeadlessException;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.util.InvalidPropertiesFormatException;
import java.util.Properties;

import org.springframework.beans.factory.xml.XmlBeanFactory;
import org.springframework.core.io.ClassPathResource;

import pds.esiag.cache.beans.HeartBeat;
import pds.esiag.cache.beans.MyCache;

import com.javamex.classmexer.MemoryUtil;

import esiag.pds.InformationManager.InformationManager;
import esiag.pds.InformationManager.InformationSource;
import esiag.pds.InformationManager.NEWInformationManager;
import esiag.pds.beans.Information;
import esiag.pds.beans.Parameters;
import esiag.psd.cacheManager.CacheManager;

public class RunServer {
		
	public static void main(String[] args) throws InvalidPropertiesFormatException, IOException {
		
		Properties props = new Properties();
        FileInputStream fis = new FileInputStream("c:/Parameters.xml");
        props.loadFromXML(fis);
        String queue= props.getProperty("queue");
        String url= props.getProperty("url");
        int maxCacheSize=Integer.parseInt(props.getProperty("maxCacheSize"));
        int expirationTime=Integer.parseInt(props.getProperty("expirationTime"));        

		HeartBeat hb= new HeartBeat();
		CacheManager chm=new CacheManager(maxCacheSize,expirationTime);
		NEWInformationManager im=new NEWInformationManager(hb,chm,queue,url);
		
		try {
			hb.start();
			Thread.sleep(4000);
			im.start();	
		} catch (Exception e) {
			// TODO: handle exception
		}
	}
}
